package util

import (
	"adminHome/pkg/setting"
	"github.com/gin-gonic/gin"
	"github.com/unknwon/com"
)

func GetPage(c *gin.Context) int {
	result := 0
	page, _ := com.StrTo(c.Query("pagenum")).Int()
	pageSize, _ := com.StrTo(c.Query("pagesize")).Int()
	if page > 0 {
		result = (page - 1) * pageSize
	}

	return result
}

func GetPageSize(c *gin.Context) int {
	pagesize, _ := com.StrTo(c.Query("pagesize")).Int()
	if pagesize != 0 {
		return pagesize
	}

	return setting.AppSetting.PageSize
}
